<?php
/**
 * <b>RUBIK IT Solution & Development ltd.</b>
 *
 * PROJECT		: Rubik Ultimate Framework
 * @version 	: 1.1
 * COPYRIGHT    : 2008
 * ------------------------------------------------------
 *  
 * @author			hoadn <hoadn@rubik.com.vn>
 *
 * Created on	: Nov 14, 2008
 */
RCoreImporter::cls('dbo.AbstractDBFinder');

/**
 * The authenticate finder for backend
 *
 */
class FrontAuthenticateFinder extends AbstractDBFinder {
	var $user_id 	= "N";
	var $username 	= "S";
	var $password 	= "MD5";
	
	function __construct($db = null){
		parent::__construct("SELECT username, password FROM member", "active = 1", '', $db);
	}
		
	/**
	 * This is the function required for authentication
	 *
	 * @param string $username
	 * @param string $password
	 * @param DataBase $db
	 * @return stdCls( username->{val}, user_type->{val2}, user_id->{val3} )
	 */
	function &getAuthenticate($username, $password = null, $db = null) {
		$finder = new FrontAuthenticateFinder($db);
		$finder->setEmptyToNull();
		$finder->username 	= $username;
		$finder->password 	= $password;
		
		if (!$db) {
			$db = SysDatabase::getInstance();
		}
		$db->setQuery($finder->getSelectSQL());
		$obj = $db->loadObject();
		return $obj;
	}
}
?>